import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel } from '../model/baseModel';

const { adminPath } = useGlobSetting();

export interface BaseApiReq extends BasicModel<BaseApiReq> {
 
}

export interface BadeApiResult extends BasicModel<BadeApiResult> {

}

export const getStockKlineData = (params?: Recordable | any) => {
  var {stockCode, period} = params;
  return defHttp.get<Recordable>({ url: adminPath+'/stock/kline/getStockKlineData/'+stockCode+'/'+period, params });
}

export const getSectorKlineData = (params?: Recordable | any) => {
  var {groupName, period} = params;
  if(groupName){
    groupName = groupName.replace('/','!');
  }
  return defHttp.get<Recordable>({ url: adminPath+'/stock/kline/getSectorKlineData/'+groupName+'/'+period, params });
}


export const fetchKlineDataHr = (params?: Recordable | any) => {
  var {stockCode, date} = params;
  return defHttp.get<Recordable>({ url: adminPath+'/stock/kline/fetchKlineDataHr/'+stockCode+'/'+date, params });
}

export const fetchKlineDataHr2 = (params?: Recordable | any) => {
  var {stockCode, date} = params;
  let year = date.substring(0, 4);
  let month = date.substring(5,7)
  return defHttp.get<Recordable>({ url: '/realStockData/'+stockCode+'/hisdata/'+year+'/'+month+'.js?d='+date, params });
}

export const getStockRsStrong = (params?: Recordable | any) => {
  var {stockCode, period} = params;
  return defHttp.get<Recordable>({ url: adminPath+'/stock/kline/getStockRsStrong/'+stockCode+'/'+period, params });
}

export const getStockPatternData = (params?: Recordable | any) => {
  var {stockCode} = params;
  return defHttp.get<Recordable>({ url: adminPath+'/stock/kline/getStockPatternData/'+stockCode, params });
}



